package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.entity.dto.ModuleRoleMiddle;
import com.qf.mapper.ModuleRoleMiddleMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ModuleRoleMiddleService extends ServiceImpl<ModuleRoleMiddleMapper,ModuleRoleMiddle> {
    @Transactional
    public void removeByRoleId(Long id) {
        QueryWrapper<ModuleRoleMiddle> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ModuleRoleMiddle::getRoleId,id);
        this.remove(wrapper);
    }

    @Transactional(readOnly = true)
    public List<ModuleRoleMiddle> getMiddleListByRoleId(Long roleId) {
        QueryWrapper<ModuleRoleMiddle> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ModuleRoleMiddle::getRoleId,roleId);
        return this.list(wrapper);
    }
}
